/*eslint-disable */
<template>
    <div>
        <!-- 首页图片 -->
        <img src="../../assets/zretc.png" style="max-width: 100%;" />
        <!-- 按钮+应用element-plus图标 -->
        <div style="height: 40px;width: 100;display: flex;align-items: center;justify-content:center;">
            <el-button class="el-button" type="primary" @click=enterBlog()>
                进入管理页<el-icon class="el-icon--right">
                    <ArrowRight style="width: 20px;height: 20px;" />
                </el-icon>
            </el-button>
        </div>
    </div>
</template>

<script lang="ts" setup>
    import {
        login,
        getUserId,
        getCurrentUserRole,
        getUserById,
} from '@/api/index'

import {ArrowRight} from '@element-plus/icons-vue'

    const enterBlog = () => {
        window.location.pathname = '/adminSearch';
    }

    login("尹桂英", "ea magna qui anim ullamco").then(
        res => {
            localStorage.setItem('token', res.data.token)
            getUserId().then(
                res => {
                    localStorage.setItem('userId', res.data);
                    getUserById(res.data).then(
                        res => {
                            localStorage.setItem('username', res.data.username)
                            localStorage.setItem('nickname', res.data.nickname)
                        }
                    )
                    getCurrentUserRole().then(
                        res => {
                            localStorage.setItem('userRole', res.data);
                        }
                    )
                }
            )
        })
</script>

<style scoped>
    .el-button {
        color: white;
        background-color: #545c64;
        border-color: #545c64;
        font-size: medium;
        width: 200px;
        height: 40px;
    }

    .el-button:hover {
        background-color: #798591;
        border-color: #545c64;
        color: white;
    }
</style>